package com.sl.rest.controllers;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
@ResponseBody
@RefreshScope
public class UserController {

    @Value("${server.port}")
    private Integer activeProfileName;

//    private static Map<String,String> map = new HashMap();
//
//    {
//        map.putAll(Arrays.asList("张三-1","李四-2","王五-3").stream().collect(Collectors.toMap(k->"profile"+k.split("-")[1],v->v.split("-")[0])));
//    }

    @GetMapping("/name")
    public Integer getName(){
//      return this.map.getOrDefault(this.activeProfileName,"未知");
        return activeProfileName;
    }
}
